package com.stx.test.serialize;

import java.io.*;
/**
 * 测试serialVersionUID不一致
 */
public class SerializeDemo {
    public static void main(String[] args) {
        User user = new User("张三", 25);
        
        try (ObjectOutputStream oos = new ObjectOutputStream(
                new FileOutputStream("D:/shuangti/user.ser"))) {
            oos.writeObject(user);
            System.out.println("对象序列化成功: " + user);
            // 程序执行后，修改User的serialVersionUID为2，在进行反序列化会报错
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}